package com.duapp.main;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class WriteToHtml {
	public final static String YOUKU = "youku.com"; 
	public final static String TUDOU = "tudou.com"; 
	public WriteToHtml(){
		
	}
	public void writeFile(String type, String id) {
		File file = new File("temp/temp.html");
		try {
			file.createNewFile();
			FileOutputStream fos = new FileOutputStream(file);
			PrintStream p = new PrintStream(fos);
			p.println(content(type, id));
			fos.close();
			p.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	private String content(String type, String id){
		if(type.equals(YOUKU)){
			return "<html>"+
					"<head>"+
					"</head>"+
					"<body scroll=\"no\" style=\"margin:0px;\">"+
						"<object type= \"application/x-shockwave-flash\" "+
							"data= \"http://static.youku.com/v1.0.0264/v/swf/loader.swf\" "+
							" width=\"600px\"  height=\"495px\" id=\"movie_player\">"+
							"<param name= \"allowFullScreen\" value=\"true\">"+
							"<param name= \"allowscriptaccess\" value=\"always\">"+
							"<param name= \"flashvars\" value=\"VideoIDS="+id+"\">"+
							"<param name= \"movie\" value=\"http://static.youku.com/v1.0.0264/v/swf/loader.swf\">"+
						"</object>"+
					"</body>"+
					"<html>";
		}else if(type.equals(TUDOU)){
			return "<html>"+
					"<head>"+
					"</head>"+
					"<body scroll=\"no\" style=\"margin:0px;\">"+
						"<object width=\"600px\" height=\"495\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" >"+
							"<PARAM NAME=\"FlashVars\" VALUE=\"iid=" + id +"\">"+
							"<PARAM NAME=\"Movie\" VALUE=\"http://js.tudouui.com/bin/player_online/TudouVideoPlayer_Homer_NewSkin_25.swf\">"+
							"<PARAM NAME=\"Src\" VALUE=\"http://js.tudouui.com/bin/player_online/TudouVideoPlayer_Homer_NewSkin_25.swf\">"+
						"<object>"+
					"</body>"+
					"</html>";

		}
		return "";
	}
	
}